package io.github.talelin.latticy.controller.zty;


import io.github.talelin.core.annotation.LoginRequired;
import io.github.talelin.latticy.common.LocalUser;
import io.github.talelin.latticy.dto.zty.ShopListDTO;
import io.github.talelin.latticy.model.UserDO;
import io.github.talelin.latticy.service.SaleListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ZTY
 * @since 2021-04-15
 */
@RestController
@RequestMapping("/saleList")
public class SaleListController {
    @Autowired
    SaleListService saleListService;

    @Autowired
    SaleListService saleListDetailService;

    @PostMapping("")
    @LoginRequired
    @Transactional
    public void createSaleList(@RequestBody ShopListDTO shopListDTO) {
        System.out.println(shopListDTO);
        UserDO localUser = LocalUser.getLocalUser();
        System.out.println(localUser);
        shopListDTO.getShopListDetails().forEach(System.out::println);
        saleListService.createSaleList(shopListDTO);
    }
}

